/***************************************************************************
 创建者：       hualei
 开始时间：    2018.09.10
 copyright:(C) 深圳市华友高科有限公司
 修改说明：（每次有修改就添加一条，带有 修改人，修改时间，修改描述）

 ***************************************************************************/
#include "tcpstartinstructiondelegate.h"
#include <QDebug>

TCPStartInstructionDelegate::TCPStartInstructionDelegate(QWidget *parent)
    : QWidget(parent)
{
}

void TCPStartInstructionDelegate::initialView()
{
    tcpStartInstructionView->noteStr = "No NoteStr";
    tcpStartInstructionView->tcpStartPort = 5059;
    tcpStartInstructionView->jmpLabelValue = 1;
    tcpStartInstructionView->tcpStartType = E_TCP_START_CLIENT;


}

void TCPStartInstructionDelegate::finishEditInstructionSlot()
{
    tcpStartInstructionView->instructionOut = tr("TCP_START ");

    QString busType;
    if(tcpStartInstructionView->tcpStartType == E_TCP_START_CLIENT)
    {
        tcpStartInstructionView->instructionOut += QString::number(tcpStartInstructionView->tcpStartServerIpVec[0]) + ".";
        tcpStartInstructionView->instructionOut += QString::number(tcpStartInstructionView->tcpStartServerIpVec[1]) + ".";
        tcpStartInstructionView->instructionOut += QString::number(tcpStartInstructionView->tcpStartServerIpVec[2]) + ".";
        tcpStartInstructionView->instructionOut += QString::number(tcpStartInstructionView->tcpStartServerIpVec[3]) + ",";
        busType = tr("CLIENT,");
    }
    else if(tcpStartInstructionView->tcpStartType == E_TCP_START_SERVER)
    {
        tcpStartInstructionView->instructionOut += QString::number(tcpStartInstructionView->tcpStartClientIpVec[0]) + ".";
        tcpStartInstructionView->instructionOut += QString::number(tcpStartInstructionView->tcpStartClientIpVec[1]) + ".";
        tcpStartInstructionView->instructionOut += QString::number(tcpStartInstructionView->tcpStartClientIpVec[2]) + ".";
        tcpStartInstructionView->instructionOut += QString::number(tcpStartInstructionView->tcpStartClientIpVec[3]) + ",";
        busType = tr("SERVER,");
    }

    tcpStartInstructionView->instructionOut += QString::number(tcpStartInstructionView->tcpStartPort) + ",";
    tcpStartInstructionView->instructionOut += busType + tr("JMP ") + tr("LB[");
    tcpStartInstructionView->instructionOut += QString::number(tcpStartInstructionView->jmpLabelValue) + "] ";
    tcpStartInstructionView->instructionOut += tr(" //") + tcpStartInstructionView->noteStr;

    qDebug() << "TCPStartInstructionDelegate::finishEditInstruction === " << tcpStartInstructionView->instructionOut;
}

void TCPStartInstructionDelegate::cleanNoteSlot()
{
    tcpStartInstructionView->noteStr.clear();

    qDebug() << "Clean The TCPStartInstruction Note!";

}
